package com.sgb.kjwl.view.ui.adapter.pick;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.MateListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class TendersAdapter extends BaseRecycleAdapter<MateListEntity> {

    private TextView purchaseTaget_tv;
    private TextView unit_tv;
    private TextView num_tv;
    private TextView g_purchaseTaget_tv;
    private TextView g_unit_tv;
    private TextView g_num_tv;
    private TextView come_time_tv;
    private TextView demand_tv;
    private TextView mark_tv;

    public TendersAdapter(Context context, List<MateListEntity> datas) {
        super(context, R.layout.item_tender, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final MateListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        purchaseTaget_tv = holder.itemView.findViewById(R.id.purchaseTaget_tv);
        unit_tv = holder.itemView.findViewById(R.id.unit_tv);
        num_tv = holder.itemView.findViewById(R.id.num_tv);
        g_purchaseTaget_tv = holder.itemView.findViewById(R.id.g_purchaseTaget_tv);
        g_unit_tv = holder.itemView.findViewById(R.id.g_unit_tv);
        g_num_tv = holder.itemView.findViewById(R.id.g_num_tv);
        come_time_tv = holder.itemView.findViewById(R.id.come_time_tv);
        demand_tv = holder.itemView.findViewById(R.id.demand_tv);
        mark_tv = holder.itemView.findViewById(R.id.mark_tv);

        purchaseTaget_tv.setText(entity.getPurchaseTaget());
        unit_tv.setText(entity.getUnit());
        num_tv.setText(entity.getNum() + "");

        g_purchaseTaget_tv.setText(entity.getPurchaseTaget());
        g_unit_tv.setText(entity.getUnit());
        g_num_tv.setText(entity.getNum() + "");

        if (entity.getApproachTime() != null) {
            come_time_tv.setText(MDateUtil.getByTimestamp(Long.parseLong(entity.getApproachTime() + ""), MDateUtil.Format.FORMART5.name));
        }
        demand_tv.setText(entity.getBrandRequire());
        mark_tv.setText(entity.getMark());
    }

}
